﻿@model IEnumerable<WebBarracoDoSom.Models.Instrumento>

@{
    ViewBag.Title = "Lista de Instrumentos";
}

<h2>Lista de Instrumentos</h2>

 <td> @Html.ActionLink("Pesquisar Instrumentos", "SearchIndex")  </td> 
@if (Request.IsAuthenticated)
{
    <td> @Html.ActionLink("Cadastar Instrumento", "Create")  </td>
}

<h2>Lista de Instrumentos</h2>

<table>
    <tr>
        <th>
            Nome
        </th>
        <th>
            Categoria
        </th>
        <th>
            Marca
        </th>
        <th>
            Descrição
        </th>
        <th>
            Foto
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Nome)
        </td>
        <td>
            @WebBarracoDoSom.Models.Categoria.Categorias.ElementAt(item.Categoria_ID).Nome
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Marca)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Descricao)
        </td>
        <td>
          <a href = @Html.DisplayFor(modelItem => item.Foto)>
            <img src=@Html.DisplayFor(modelItem => item.Foto) height="100" width="100" />
          </a> 
        </td>
        <td>
         @if (Request.IsAuthenticated && User.Identity.Name == "0" || User.Identity.Name == "1")
         {
            @Html.ActionLink("Editar", "Edit", new { id=item.ID }) 
            @Html.ActionLink("Deletar", "Delete", new { id=item.ID })
         }
            @Html.ActionLink("Detalhes", "Details", new { id=item.ID })
            @Html.ActionLink("Alugar", "Create", "Emprestimo", new {instrumentoID = item.ID}, new {instrumentoID = item.ID})
        </td>
    </tr>
}

</table>
